Introduction

The Diffie-Hellman key exchange protocol allows two parties, Alice and Bob, to agree on a secret key without having exchanged any secret information beforehand! The method is based in cyclic groups, so read up on that in the mathematical prerequisites.

Diffie-Hellman Key Exchange

The protocol itself is based on the group , where is some huge prime number. The prime numbers that can be used in the Diffie-Hellman (DH) key exchange are standardised - they are public knowledge and can be found in various RFCs on the Internet. More specifically, the prime must be a safe prime, i.e. a prime such that , where is also prime.

Example: Diffie-Hellman Primes

One such prime can be found in RFC 3526 and is 4096 bits long.

Notice that since , the prime divides and so the group has an element of order and the powers of generate the group . It turns out that this group is a subgroup of . We are now ready to outline the DH key exchange.

The primes as well as the generator are public knowledge and are standardised in various RFCs.

Alice picks a random power between and , i.e. a uniform and computes . Similarly, Bob picks a uniform and computes . Alice and Bob then exchange the values and which they computed - Alice obtains from Bob and Bob obtains from Alice.

Alice now computes and Bob computes - the two parties have arrived at the same key ! Interestingly enough, any eavesdropping adversary cannot arrive at the same value by just observing the communication channel, since they do not know the secret values and which Alice and Bob picked separately for themselves.

AliceBobEve
knownknownknown
knownknownknown
knownknownknown
knownunknownunknown
unknownknownunknown
knownknownknown
knownknownknown
knownknownunknown

The Diffie-Hellman Problems

The security of the Diffie-Hellman protocol is defined according to certain mathematical problems.

In trying to break the Diffie-Hellman key exchange, the adversary Eve is in a way trying to solve the discrete logarithm problem. The function denotes the discrete logarithm function with base and is the function that returns the power which you need to raise to in order to obtain , i.e. Eve is trying to compute . The logarithm is called discrete because it only returns integer values due to the fact that we are working with groups

Definition: The Discrete Logarithm Problem

The adversary is given the generator as well as the order of the generated group and is provided with the group element for some uniform, unknown, . Her goal is to find the value of .

We say that the discrete logarithm problem is hard relative to if no matter what Eve does, the probability that she can find is negligible, i.e.

It should be obvious that the computational difficulty of the discrete logarithm largely depends on the group itself and so not every group yields a secure Diffie-Hellman key exchange.

There are two additional problems which are similar to the discrete logarithm problem and are known to be related but not equivalent to the each other.

Definition: The Computational Diffie-Hellman (CDH) Problem

The adversary is given the generator as well as the order of the generated group and is provided with two group elements and for some uniform, unknown, . Her goal is to then find the value of .

We say that the computational diffie-hellman problem is hard relative to if, no matter what Eve does, the probability that she can find is negligible, i.e.

The CDH problem is essentially an exact description of the Diffie-Hellman scenario. Eve can observe the communication between Alice and Bob and is thus able to obtain the values and . However, Alice and Bob ultimately end up using the value as a key and so Eve has to find a way to compute it using only and .

The second problem is related to the CDH problem but the two problems are not known to be equivalent.

Definition: The Decisional Diffie-Hellman (DDH) Problem

The adversary knows the cyclic group , one of its generators and its order . She is given two group elements which are generated by for some uniform, unknown to Eve, powers . Finally, Eve is either given a third such element generated by some uniform unknown or she is given the element . Eve's goal is to then determine if she has or .

We say that the DDH problem is hard relative to if no matter what Eve does, the probability that she achieves her goal is negligible, i.e.

If the CDH problem is easy relative to some group, then so is the DDH problem.